

snippet ngc "Define a new Angular Controller. You can change the controller name and parameters."
${1:controllerName} = (${2:scope}, ${3:injectables}) ->
  $0
endsnippet


snippet ngfor "angular.foreach loop"
angular.forEach ${1:iterateOver}, (value, key) ->
  $0
endsnippet


snippet ngm "A new angular module without a config function."
angular.module '${1:moduleName}', [${2:moduleDependencies}]
$0
endsnippet


snippet ngma "A new angular module without a config function and a variable assignment."
${1:moduleName} = angular.module '$1$', [${2:moduleDeps}]
$0
endsnippet


snippet ngmc "A new angular module with a config function"
${1:moduleName} = angular.module('$1', [${2:moduleDeps}], (${3:configDeps}) ->
  $0
)
endsnippet


snippet ngmfa "A factory in a module"
factory '${1:factoryName}', (${2:dependencies}) ->
  $0
endsnippet


snippet ngms "Define an Angular Module Service to be attached to a previously defined module. You can change the service name and service injectables."
service '${1:serviceName}', (${2:injectables}) ->
  $0
endsnippet


snippet ngmfi "Define an Angular Module Filter to be attached to a previously defined module. You can change the filter name."
filter '${1:filterName}', (${2:injectables}) ->
  (input, ${3:args}) ->
    $0
endsnippet



# Route Based Snippets
snippet ngrw "Defines a when condition of an AngularJS route."
$routeProvider.when '${1:url}',
  templateUrl: '${2:templateUrl}' 
  controller: '${3:controller}'
$0
endsnippet



snippet ngrwr "Defines a when condition of an AngularJS route with the resolve block."
$routeProvider.when '${1:url}'
  templateUrl: '${2:templateUrl}' 
  controller: '${3:controller}'
  resolve:
    $4
$0
endsnippet


snippet ngro "Defines an otherwise condition of an AngularJS route."
$routeProvider.otherwise redirectTo: '${1:url}'
$0
endsnippet


# Scope Related Snippets
snippet $f "Define a new $scope'd function (usually inside an AngularJS Controller). You can change the function name and arguments."
$scope.${1:functionName} = (${2:args}) ->
  $0
endsnippet


snippet $v "Defines a new $scope'd variable inside an AngularJS controller."
$scope.${1:variable} = ${2:value}
$0
endsnippet


snippet $va "Defines a new $scope'd variable inside an AngularJS controller and assigns a value from a constructor arguments."
$scope.${1:variable} = ${2:variable}
$0
endsnippet


snippet $w "Define a $watch for an expression. You can change the expression to be watched."
$scope.$watch '${1:watchExpr}', (newValue, oldValue) ->
  $0
endsnippet


snippet $on "Define a $on for a $broadcast/$emit on the $scope inside an Angular Controller. You can change the event name to listen on."
$scope.$on '${1:eventName}', (event, ${2:args}) ->
  $0
endsnippet


snippet $b "Define a $broadcast for a $scope inside an Angular Controller / Angular Controller Function. You can change the event name and optional event arguments."
$scope.$broadcast '${1:eventName}', ${2:eventArgs}
$0
endsnippet


snippet $e "Define an $emit for a $scope inside an Angular Controller / Angular Controller Function. You can change the event name and optional event arguments."
$scope.$emit '${1:eventName}', ${2:eventArgs}
$0
endsnippet


# Directive related snippets
snippet ngdcf "A compile function"
compile = (tElement, tAttrs, transclude) ->
  (scope, element, attrs) ->
    $0
endsnippet


snippet ngdlf "A linking function in a directive."
(scope, element, attrs${1:ctrl}) ->
  $0
endsnippet


snippet ngdc "A directive with a compile function"
directive '${1:directiveName}', factory(${2:injectables}) ->
  directiveDefinitionObject =
    ${3:directiveAttrs}
    compile: compile = (tElement, tAttrs, transclude) ->
      (scope, element, attrs) ->
  directiveDefinitionObject
endsnippet


snippet ngdl "A directive with a linking function only."
.directive('${1:directiveName}', (${2:directiveDeps}) ->
  (scope, element, attrs${3:ctrl}) ->
    $0
)
endsnippet


# vim:ft=snippets:
